<?xml version="1.0" encoding="utf-8"?>
<CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
	<CodeSnippet Format="1.0.0">
		<Header>
			<Title>Controller</Title>
			<Shortcut>gctrl</Shortcut>
			<Description>ZEQP Controller自动生成</Description>
			<Author>ZEQP</Author>
			<SnippetTypes>
				<SnippetType>Expansion</SnippetType>
				<SnippetType>SurroundsWith</SnippetType>
			</SnippetTypes>
		</Header>
		<Snippet>
			<Declarations>
				<Literal>
					<ID>name</ID>
					<ToolTip>实体名称</ToolTip>
					<Default>CF_Entity</Default>
				</Literal>
			</Declarations>
			<Code Language="csharp">
        <![CDATA[using System;
using PMS.SANY.Entity;
using PMS.SANY.IBusiness;
using PMS.SANY.Models;
using PMS.SANY.Util;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.Extensions.DependencyInjection;

namespace PMS.SANY.Api.Controllers
{
    /// <summary>
    /// $name$
    /// </summary>
    public class $name$Controller : BaseController
    {
        public I$name$Business Bus { get; set; }
        public IServiceProvider SvcProvider { get; set; }
        public $name$Controller(I$name$Business bus, IServiceProvider svcProvider)
        {
            this.Bus = bus;
            this.SvcProvider = svcProvider;$end$
        }

        /// <summary>
        /// 获取单个实体
        /// </summary>
        /// <param name="id">主键</param>
        /// <returns></returns>
        [HttpGet]
        public Task<$name$> GetAsync(string id)
        {
            return this.Bus.GetAsync(id, true);
        }

        /// <summary>
        /// 获取分页数据
        /// </summary>
        /// <param name="query">查询条件</param>
        /// <returns></returns>
        [HttpPost]
        public Task<PageResult<$name$>> GetPageAsync(PageInput<$name$QM> query)
        {
            return this.Bus.GetPageResultAsync(query);
        }

        /// <summary>
        /// 保存数据
        /// </summary>
        /// <param name="data">对应数据</param>
        /// <returns></returns>
        [HttpPost]
        [Transaction]
        public Task<int> SaveAsync($name$ data)
        {
            this.InitBusEntity(data);
            return this.Bus.AddOrUpdateAsync(data);
        }

        /// <summary>
        /// 批量删除数据
        /// </summary>
        /// <param name="ids">数据主键</param>
        /// <returns></returns>
        [HttpDelete]
        [Transaction]
        public Task<int> DeleteAsync(List<string> ids)
        {
            return this.Bus.DeleteAsync(ids);
        }
    }
}
]]>
			</Code>
		</Snippet>
	</CodeSnippet>
</CodeSnippets>
